<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .container {
            margin: 12px;
            width: 200px;
            height: 200px;
            border: 1px solid lightgray;
        }

        /* 黑白相间格子背景 */
        .grid-bg-1 {
            background: conic-gradient(#ccc 0 25%, transparent 25% 50%, #ccc 50% 75%, transparent 75%);
            background-size: 20px 20px;
        }

        /* 网格背景 */
        .grid-bg-2 {
            background: linear-gradient(transparent 0px, transparent calc(100% - 1px), #ccc calc(100% - 1px), #ccc 100%),
                linear-gradient(90deg, transparent 0px, transparent calc(100% - 1px), #ccc calc(100% - 1px), #ccc 100%);
            background-size: 20px 20px;
            /* 往右下角偏移半个网格线宽度 */
            background-position: 0.5px 0.5px;
        }

        /* grid布局实现网格背景 */
        .grid-bg-3 {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            grid-template-rows: repeat(4, 1fr);
            gap: 2px;
            background-color: #ccc;
        }

        .grid-item {
            background-color: white;
            display: flex;
            justify-content: center;
            align-items: center;
        }
    </style>
</head>

<body>
    <div class="container grid-bg-1"></div>
    <div class="container grid-bg-2"></div>
    <div class="container grid-bg-3">
        <div class="grid-item">1</div>
        <div class="grid-item">2</div>
        <div class="grid-item">3</div>
        <div class="grid-item">4</div>
        <div class="grid-item">5</div>
        <div class="grid-item">6</div>
        <div class="grid-item">7</div>
        <div class="grid-item">8</div>
        <div class="grid-item">9</div>
        <div class="grid-item">10</div>
        <div class="grid-item">11</div>
        <div class="grid-item">12</div>
        <div class="grid-item">13</div>
        <div class="grid-item">14</div>
        <div class="grid-item">15</div>
        <div class="grid-item">16</div>
    </div>
</body>

</html>